package demo1;

class MyArray<E>{
    public Object[] array = new Object[10];

    public void setArray(int pos, E value){
        array[pos] = value;
    }

    public E getAaary(int pos){
        return (E)array[pos];
    }

//    public<E extends Comparable<E>> E find(E[] arr){
//        return arr[0];
//    }

    public static <E> void find(E[] arr){
        //...
    }
}

class Array<E extends Number>{

}

public class Test {
    public static void main(String[] args) {
        Integer[] a = {1,2,3,4,5,6};
        MyArray.find(a);
        MyArray.<Integer>find(a);
    }

    public static void main3(String[] args) {
        Array<Integer> arr1 = new Array<>();
        Array<Double> arr2 = new Array<>();
        //Array<String> arr3 = new Array<String>();//编译错误
    }

    public static void main2(String[] args) {
        MyArray<String> arr1 = new MyArray<String>();
        MyArray<Integer> arr2 = new MyArray<>();//类型推导，省略后面的类型
        MyArray arr3 = new MyArray();//裸类型不推荐使用，没有编译器检查，是为了兼容老版本
    }

    public static void main1(String[] args) {
        Integer a = 127;
        Integer b = 127;

        Integer c = 128;
        Integer d = 128;

        System.out.println(a == b);
        System.out.println(c == d);
    }
}
